package model.actions;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import metier.GameState;
import metier.Objet;
import model.Sound;

public class PlaySoundAction extends Action {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1850925016150367436L;
	protected String path;

	public PlaySoundAction() {
		super();
	}

	public PlaySoundAction(String path) {
		super();
		this.path = path;
	}

	@Override
	public void commit(GameState state, Objet sender) {
		new Thread() {
			@Override
			public void run() {
				super.run();
				Sound player = new Sound(path, 0);
				InputStream stream = new ByteArrayInputStream(player.getSamples());
				player.play(stream);
			}
		}.start();
		
	}

}
